package io.renren.modules.orginfo.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import io.renren.modules.wmunnormal.entity.WmunnormalEntity;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.renren.modules.orginfo.entity.OrginfoEntity;
import io.renren.modules.orginfo.service.OrginfoService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2023-02-06 18:27:47
 */
@RestController
@RequestMapping("orginfo/orginfo")
public class OrginfoController {
    @Autowired
    private OrginfoService orginfoService;

    @GetMapping("getOrg")
    public List<OrginfoEntity> getOrg(@RequestParam(value = "orgName",required = false) String orgName){
        return orginfoService.getOrg(orgName);
    }

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("orginfo:orginfo:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = orginfoService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{orgid}")
    @RequiresPermissions("orginfo:orginfo:info")
    public R info(@PathVariable("orgid") Integer orgid){
		OrginfoEntity orginfo = orginfoService.getById(orgid);

        return R.ok().put("orginfo", orginfo);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("orginfo:orginfo:save")
    public R save(@RequestBody OrginfoEntity orginfo){
		orginfoService.save(orginfo);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("orginfo:orginfo:update")
    public R update(@RequestBody OrginfoEntity orginfo){
		orginfoService.updateById(orginfo);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("orginfo:orginfo:delete")
    public R delete(@RequestBody Integer[] orgids){
		orginfoService.removeByIds(Arrays.asList(orgids));

        return R.ok();
    }

}
